package logic

import (
	"context"
	"share/common"
	"share/models"

	"share/internal/svc"
	"share/pb/share"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteShareLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteShareLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteShareLogic {
	return &DeleteShareLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// DeleteShare 删除分享
func (l *DeleteShareLogic) DeleteShare(in *share.ShareInfo) (*share.Empty, error) {
	err := l.svcCtx.ShareModel.Update(l.ctx, &models.Share{Id: in.Id, Status: common.ShareDelete})
	if err != nil {
		return nil, err
	}
	return &share.Empty{}, nil
}
